#pragma once
#include <ncnn/net.h>
#include <ncnn/cpu.h>
#include <string>
#include <opencv2/opencv.hpp>
#include "NcnnUtil.h"

namespace Ncnn
{
	class RecNet
	{
    public:
        RecNet();

        ~RecNet() {};

        int read_model(std::string param_path = "data/ch_recv4.ncnn.param",
            std::string bin_path = "data/ch_recv4.ncnn.bin",
            std::string key_path = "data/dict_chi_sim.txt", bool use_gpu = false);

        int read_keys(std::string key_path);


        bool detect(cv::Mat& src, TextLine& result);

        bool detect(std::vector<cv::Mat>& src, std::vector<TextLine>& results);

    private:
        TextLine scoreToTextLine(const std::vector<float>& outputData, int h, int w);

    private:
        ncnn::Net net;
        const int dstHeight = 48;
        const int dstWidth = 320;
        const float meanValues[3] = { 127.5, 127.5, 127.5 };
        const float normValues[3] = { 1.0 / 127.5, 1.0 / 127.5, 1.0 / 127.5 };

        std::vector<std::string> keys;
	};
}

